<template>
	<view>
		<view class="top" style="padding: 32upx;">
			<view style="text-align: center;color: #c3d9cf;height: 36upx;line-height: 36upx;" v-cloak> v-cloakres.coinname}}余额</view>
			<view style="font-size: 60upx;text-align: center;height: 90upx;line-height: 90upx;" v-cloak>{{res.walletPrice}}</view>
			<view class="clear">
				<view class="nav">
					<view v-cloak>{{res.coinname}}结算价（元）</view>
					<view v-cloak>{{res.coinrate}}</view>
				</view>
				<view class="nav">
					<view v-cloak>我的{{res.coinname}}购买力（元）</view>
					<view v-cloak>{{res.mygm}}</view>
				</view>
			</view>
		</view>
		<view style="background: #fff;padding-top: 20upx;">
			<image :src="res.addressQrcode" mode="" style="width: 320upx;height: 320upx;display: block;margin: 0 auto;"></image>
			<view style="text-align: center;font-size: 32upx;">充值地址</view>
			<view style="font-size: 24upx;text-align: center;color: #0e9b52;" v-cloak>{{res.coinaddress2}}</view>
			<view class="arrow">
				<view class="list" style="z-index: 2;"></view>
				<view class="list" style="margin-top: 5px;opacity: .6;z-index: 1;"></view>
				<view class="list" style="margin-top: 10px;opacity: .3;z-index: 0;"></view>
			</view>
		</view>
		<view>
			<view style="padding: 20upx 30upx;background: #fff;border-bottom: 1px solid #eaeaea;margin-top: 20upx;">用户须知</view>
			<view style="padding: 20upx 50upx;background: #fff;color: #666;" class="tip">
				<view>1、扫描"商城充值二维码"或点击"转入"按钮，复制您的钱包地址；</view>
				<view>2、打开您的钱包APP，进入转账页面，粘贴充值地址，确认进行转账操作；</view>
				<view>3、等待以太坊网络区块节点同步确认，MG商城将实时到账。如遇区块拥堵，请您耐心等待</view>
			</view>
		</view>
		<view style="position: fixed;bottom: 0;width: 100%;" class="clear footer">
			<button type="default" style="background: #eee;" @click="jump">转出</button>
			<button type="primary" style="color: #fff;" @click="copy">转入</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				res:[],
				openid:''
			};
		},
		onLoad(e) {
			uni.showLoading()
			uni.getStorage({
				key: 'openid',
				success: (res) => {
					this.openid = res.data
					this.setAjax(e.coin)
				},
				fail: () => {
					uni.navigateTo({
						url: '../../login/login'
					});
				}
			});
		},methods:{
			setAjax(coin){
				uni.request({
					url: 'http://hszj.hongshantang696.com//app/index.php?i=4&c=entry&m=ewei_shopv2&do=mobile&r=coin.detail&app=1',
					method: 'POST',
					data: {'openid':this.openid,'cointitle':coin},
					header:{'Content-Type':'application/x-www-form-urlencoded'},
					success: res => {
						uni.hideLoading()
						uni.setNavigationBarTitle({
							title: res.data.coinname
						})
						console.log(res.data)
						this.res = res.data
					},
					fail: () => {},
					complete: () => {}
				});
			},
			jump(){
				uni.request({
					url: 'http://hszj.hongshantang696.com//app/index.php?i=4&c=entry&m=ewei_shopv2&do=mobile&r=coin.tbsq&app=1&openid='+this.openid,
					success: res => {
						if(res.data.error == 1){
							uni.navigateTo({
								url: '../../tips/tips?message='+res.data.message
							});
						}else{
							uni.navigateTo({
								url: '../tbsq/tbsq'
							});
						}
					},
					fail: () => {},
					complete: () => {}
				});
			},
			copy(){
				uni.setClipboardData({
					data: this.res.coinaddress2,
					success: function () {
						uni.showModal({
							content: "复制成功",
							showCancel: false
						})
					}
				})
			}
		},
		onNavigationBarButtonTap:function(e){
			uni.navigateTo({
				url: '../log?cointitle='+this.res.cointitle
			});
        }
	}
</script>

<style>.top{background:#175e3c;}.top view{color:#e2fcfb;font-size:24upx;}.nav{float:left;width:50%;padding-left:40upx;box-sizing:border-box;margin-top:20upx;}.arrow{height:80upx;position:relative;margin-top:24upx;}.arrow view{position:absolute;left:50%;margin-left:-10px;list-style:none;top:-15px;}.arrow view:after{content:"";display:block;width:20upx;height:20upx;background:#175e3c;margin-left:10upx;}.arrow view:before{content:"";display:block;width:0;height:0;border:20upx solid transparent;border-bottom-color:#175e3c;}.tip view{line-height:40upx;margin-bottom:10upx;}.footer{box-shadow:0 0 4px rgba(0,0,0,0.1);-webkit-box-shadow:0 0 4px rgba(0,0,0,0.1);-moz-box-shadow:0 0 4px rgba(0,0,0,0.1);}.clear button{float:left;width:50%;border-radius:0;color:#175e3c;background:#175e3c;}.clear button:after{display:none;}</style>